<style>
	#datas tr{cursor : pointer;}
</style>
<div class="clearfix form-inline">
	<ul class="nav pull-left">
		<li class="pull-left">{:L('SEARCH_CONDITION')}
			<select style="width:auto" name="field" id="field" onchange="changeCondition()">
				<option class="role" value="owner_role_id">{:L('OWNER_ROLE')}</option>
				<option class="word" value="name">{:L('COMPANY_NAME')}</option>
				<option class="word" value="contacts_name">{:L('CONTACTS_NAME')}</option>
				<option class="word" value="mobile">{:L('TELPHONE')}</option>
				<option class="word" value="email">{:L('EMAIL')}</option>
			</select>&nbsp;&nbsp;
		</li>
		<li id="conditionContent" class="pull-left">
			<select class="form-control" id="condition" style="width:auto" name="condition" onchange="changeSearch()">
				<option value="contains" <if condition = "$search_field['condition'] eq 'contains'">selected</if>>{:L('CONTAINS')}</option>
				<option value="not_contain" <if condition = "$search_field['condition'] eq 'not_contain'">selected</if>>{:L('NOT_CONTAIN')}</option>
				<option value="is" <if condition = "$search_field['condition'] eq 'is'">selected</if>>{:L('IS')}</option>
				<option value="isnot" <if condition = "$search_field['condition'] eq 'isnot'">selected</if>>{:L('ISNOT')}</option>						
				<option value="start_with" <if condition = "$search_field['condition'] eq 'start_with'">selected</if>>{:L('START_WITH')}</option>
				<option value="end_with" <if condition = "$search_field['condition'] eq 'end_with'">selected</if>>{:L('END_WITH')}</option>
				<option value="is_empty" <if condition = "$search_field['condition'] eq 'is_empty'">selected</if>>{:L('IS_EMPTY')}</option>
				<option value="is_not_empty" <if condition = "$search_field['condition'] eq 'is_not_empty'">selected</if>>{:L('IS_NOT_EMPTY')}</option>
			</select>&nbsp;&nbsp;
		</li>
		<li id="searchContent" class="pull-left">
			<input id="search" type="text" class="input-medium search-query" name="search" value="{$search_field['search']}" onkeydown="if(event.keyCode==13)changeCondition1(0)"/>&nbsp;&nbsp;
		</li>
		<li class="pull-left">
			<button type="button" class="btn btn-primary" onclick="changeCondition1()">{:L('SEARCH')}</button>
		</li>
	</ul>
</div>
<empty name="leadsList">
	<div style="clear:both">
		<include file="Public:nodata" />
	</div>
<else/>
	<table class="table table-hover">
		<thead>
			<tr style="background-color:#F5F5F6;">
				<th></th>
				<th width="40%">{:L('COMPANY_NAME')}</th>
				<th width="20%">{:L('CONTACTS')}</th>
				<th width="18%">{:L('TELPHONE')}</th>
				<th width="18%">{:L('EMAIL')}</th>
			</tr>
		</thead>
		<tfoot id="footers">
			<tr>
				<td colspan="5">
					{$page}
				</td>
			</tr>
		</tfoot>
		<tbody id="datas">
			<volist name="leadsList" id="vo">
				<tr> 
					<td><input type="radio" name="leads" class="leads_id" value="{$vo.leads_id}"/></td>
					<td>{$vo.name}</td>
					<td>{$vo.contacts_name}</td>
					<td>{$vo.mobile}</td>
					<td>{$vo.email}</td>
				</tr>
			</volist>
		</tbody>
	</table>
	<script type="text/javascript">
		$('#go_page').change(function(){
			var sel = $(this).val();
			$('#dialog-leads').load(sel);
			return false;
		});
		$("#datas tr").click(function(){
			$(this).find('td:first-child .leads_id').prop('checked', true);
		});
		$(function(){
			$('#footers a').click(function(){ 
				var rel = $(this).attr('href'); 
				$('#dialog-leads').load(rel);   
				return false;
			});
		}); 
		function changeCondition1(){
			var field = $('#field option:selected').val();
			var condition = $('#condition option:selected').val();
			var search = $('#search').val();
			var url = "{:U('leads/listDialog','&field=')}"+field+'&condition='+condition+'&search='+search;
			$('#dialog-leads').load(url);
		}
	</script>
</empty>